//
//  LGCarePlanTaskReviewCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/9/19.
//  新增、编辑任务 -- 复诊复查Cell

#import "LGCarePlanTaskReviewCell.h"

@interface LGCarePlanTaskReviewCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;
/**   */
@property (nonatomic , strong)UIButton *selectBtn;

@end

@implementation LGCarePlanTaskReviewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.clipsToBounds = YES;
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.baseView];
        [self.baseView addSubview:self.contentLabel];
        [self.baseView addSubview:self.selectBtn];
        [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(viewPix(16));
            make.right.equalTo(self.contentView).offset(-viewPix(16));
            make.top.bottom.equalTo(self.contentView);
        }];
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.baseView).offset(viewPix(8));
            make.left.equalTo(self.baseView).offset(viewPix(12));
            make.right.equalTo(self.selectBtn.mas_left).offset(-viewPix(12));
            make.bottom.equalTo(self.baseView).offset(-viewPix(8));
        }];
        [self.selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.baseView).offset(-viewPix(12));
            make.width.height.equalTo(@(viewPix(24)));
            make.centerY.equalTo(self.baseView);
        }];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.contentLabel.text = LGNSString(dataDic[@"title"]);
    self.selectBtn.selected = [LGNSString(dataDic[@"is_checked"]) isEqualToString:@"0"]?NO:YES;
}

-(void)setTitle:(NSString *)title{
    _title = title;
    self.contentLabel.text = title;
}

-(void)setIsSelect:(BOOL)isSelect{
    _isSelect = isSelect;
    self.selectBtn.selected = isSelect;
}

#pragma mark
#pragma mark ====> 创建控件
-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B3C5D9" offset:CGSizeMake(0, 2) opacity:0.15 radius:0];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(15) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _contentLabel;
}

-(UIButton *)selectBtn{
    if(!_selectBtn){
        _selectBtn = [UIButton buttonWithImage:@"unselect24" selectImage:@"selected24"];
        _selectBtn.userInteractionEnabled = NO;
    }
    return _selectBtn;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
